--Enemy Units are spawned once the player's 'x' value is greater than 1200.

function gadget:GetInfo()
	return {
		name	= "Ambush Gadget",
		desc	= "Creates enemy units that ambush you.",
		author	= "Marcus",
		date	= "uhh..",
		license	= "None, just testing for fun",
		layer = 0,
		enabled	= false
	}
end

if not gadgetHandler:IsSyncedCode() then return end


local transferUnit = Spring.TransferUnit
local trip = false

 function gadget:Initialize()
	initFrame = Spring.GetGameFrame()
end

function gadget:GameFrame(n)
	unit = Spring.GetTeamUnits(0)[1]
	local x, y, z = Spring.GetUnitPosition(unit)
	--Spring.Echo("X = ", x)
	--Spring.Echo("Y = ", y)
	--Spring.Echo("Z = ", z)
	if (x > 1000 and trip == false) then  
		trip = true
		local unitID = Spring.CreateUnit("bheavyassaultmech", x - 200, y, z, "e", 1, false)
		unitID = Spring.CreateUnit("bheavyassaultmech", x + 200, y, z, "w", 1, false)
		unitID = Spring.CreateUnit("bheavyassaultmech", x, y, z + 200, "n", 1, false)
		unitID = Spring.CreateUnit("bheavyassaultmech", x, y, z - 200, "s", 1, false)
		Spring.Echo(unitID)
	end
end